package com.service.Impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.entity.SharesZdfTrend000;
import com.mapper.SharesZdfTrend000Mapper;
import com.service.SharesZdfTrend000Service;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author pumpkin
 * @since 2021-03-15
 */
@Service
public class SharesZdfTrend000ServiceImpl extends ServiceImpl<SharesZdfTrend000Mapper, SharesZdfTrend000> implements SharesZdfTrend000Service {


    @Override
    public void getPord() {
        Map<String,Integer> prodMap=new HashMap<>();
        Map<String,Integer> numMap=new HashMap<>();
        //查找7天的，放入map
        Wrapper<SharesZdfTrend000> wr=new EntityWrapper<>();
        wr.and("length(trend)=16");
        List<SharesZdfTrend000> sharesZdfTrend000s = this.selectList(wr);

        if(!CollectionUtils.isEmpty(sharesZdfTrend000s)){
            for (SharesZdfTrend000 sharesZdfTrend000 : sharesZdfTrend000s) {
                String trend = sharesZdfTrend000.getTrend();
                Integer num = sharesZdfTrend000.getNum();

                Integer integer = prodMap.get(trend);
                if(null==integer){
                    prodMap.put(trend,1);
                }else{
                    integer= integer+num;
                    prodMap.put(trend,integer);
                }

                String s = trend.replaceAll("\\d+", "");
            }
        }
    }
}
